package com.school.appleforgetbackend.controller;

import com.school.appleforgetbackend.BO.request.Request;
import com.school.appleforgetbackend.BO.response.*;
import com.school.appleforgetbackend.service.WeldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


/**
 *
 * **/
@Controller
@RequestMapping("/weld")
//@CrossOrigin(origins = {"http://127.0.0.1:80","http://127.0.0.1:8080","http://172.16.11.40:80","http://172.16.11.40:7780","http://localhost:8080","http://192.168.31.79:8080","http://103.236.70.225:8093","http://103.236.70.225:8092","http://103.236.70.225:7780","http://103.236.70.225:8088"},
//        allowCredentials = "true")
public class WeldController {

    @Autowired
    private WeldService weldService;

    /**
     *
     **/
    @RequestMapping(value = "/welding")
    @ResponseBody
    public WeldResponse getWeld(@RequestBody Request request){
        String param = request.getMessage().getDevice_id();
        // 先检查param是否为null
        if (param == null) {
            System.out.println("Param is null");
            return null;
        }
        if (param.equals("WM1")){
            WeldResponse weldResponse = weldService.getWeld();
           return weldResponse;
        }
        if (param.equals("WM2")){
            WeldResponse weldResponse = weldService.getWeld2();
            return weldResponse;
        }
        if (param.equals("WM4")){
            WeldResponse weldResponse = weldService.getWeld4();
            return weldResponse;
        }
        if (param.equals("WM5")){
            WeldResponse weldResponse = weldService.getWeld5();
            return weldResponse;
        }
        WeldResponse weldResponse = null;
        System.out.println(weldResponse);
        return weldResponse;
    }

//    @RequestMapping(value = "/welding2")
//    @ResponseBody
//    public WeldResponseA getWeld2() {
//        WeldResponseA weldResponse = weldService.getWeld2();
//        System.out.println(weldResponse);
//        return weldResponse;
//    }
//
//    @RequestMapping(value = "/welding4")
//    @ResponseBody
//    public WeldResponseB getWeld4() {
//        WeldResponseB weldResponse = weldService.getWeld4();
//        System.out.println(weldResponse);
//        return weldResponse;
//    }
//
//    @RequestMapping(value = "/welding5")
//    @ResponseBody
//    public WeldResponseC getWeld5() {
//        WeldResponseC weldResponse = weldService.getWeld5();
//        System.out.println(weldResponse);
//        return weldResponse;
//    }


}

